Linux コマンドメモ
#Linux
\を最初につけることで、エイリアスが無効になる
rsync
a archive mode; equals -rlptgoD (no -H,-A,-X)
the ‘H’ option copies hardlinks
the ‘A’ option copies ACLs
the ‘X’ option copies extended attributes
the ‘x’ option don’t cross file system boundaries
the ‘S’ option handle sparse files efficiently
the ‘P’ option displays progress
https://linux.die.net/man/1/rsync
fuser
https://webkaru.net/linux/fuser-command/
ファイルやソケットを使用しているプロセスを特定
fuser -muv マウントポイント
u ユーザー
v commandの詳細情報を表示
htop
https://linux.die.net/man/1/htop
F9でkillモード
killシグナルのタイプを選択
code:xclip
# systemc clipboardにコピーできる
# パイプでつなげて、コンソール出力を渡すといい感じ
xclip -selection clipboard
find [指定フォルダパス] -type f -name "*.txt" | head -n 50
指定フォルダパスで、ファイル名検索。
find . -type f -newer newer
再帰的にファイル名を置換する
rename {before} {after} **/*.txt
ip -c
-c color出力
rm -i
-i は実行前に確認プロンプト表示
useradd
https://linux.die.net/man/8/useradd
-c comment username fullname
nologinは -s ~/nologin のようにnologinを指定すれば良い。
w
ログインしているユーザーと実行中のプロセスを表示する
shred
ディスク完全削除
https://webkaru.net/linux/shred-command/
wc
文字数や行数カウント
-l
行数をカウント
code:du
#1階層
du -h --max-depth=1
code:convmv
#ファイル名をutf-8に変換
# * currentディレクトリのファイル全て
convmv -r -f cp932 -t utf-8 --notest *
code:iconv
`
iconv -f utf8 -t sjis sample.txt -c > sample.txt
# -cで変換できない文字列をスキップする
code:rename
#ファイル名の一括置換
#正規表現可
# htmをhtmlの拡張子に変換
rename htm html *.htm
grep
-v 除外する
code:diff
diff -u in.txt in2.txt | grep ^+ | grep -v ^+++
code:tree
tree -I "*.html|*.png|*.jpg"
code:fuser
fuser -f
https://www.ibm.com/support/knowledgecenter/ja/SSLTBW_2.2.0/com.ibm.zos.v2r2.bpxa500/fuser.htm
cp -r ./.
dotfileもコピーする
https://eng-entrance.com/linux-command-join
sqlのjoinみたい
片方にしか存在しない場合切り捨てられる
code:join
# 一致に使う項目を2番目に指定する
# -j オプション無しでは1番目になる
join -j 2
ls -lSr
-S ファイルサイズ